package com.ellricky.baselib.adapter.course

import android.os.Bundle
import android.view.View
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.BaseConstant
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.entity.new.StudentOutList
import com.ellricky.baselib.ui.base.BaseRefreshFragment
import com.ellricky.baselib.util.NewEBaseCallback
import com.ellricky.baselib.util.NewEListCallback

class MakeUpCourseFragment : BaseRefreshFragment<Void, BasePresenter<Void>, StudentOutList>() {

    private var state = "6"

    override fun getResponseCallback2(): NewEBaseCallback {
        return object : NewEListCallback<StudentOutList>(mContext, false) {
            override fun onSuccess(data: MutableList<StudentOutList>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(data, refresh)
            }
        }
    }

    override fun initUIView(view: View?) {
        super.initUIView(view)
        hideToolBar()
        state = arguments?.getString(BaseConstant.KEY_ID, "") ?: ""
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<StudentOutList> {
        return MakeUpAdapter(activity!!)
    }

    override fun getUrlPath(): String {
        return ""
    }

    override fun initParamMap() {
        super.initParamMap()
        paramMap["action"] = getAction()
        paramMap["school_id"] = LocalCacheUtil.getSchoolId()
        paramMap["eid"] = LocalCacheUtil.getUid()
        paramMap["course_state"] = state
    }

    override fun getResponseCallback(): BaseCallback? {
        return null
    }

    private fun getAction(): String {
        return when (LocalCacheUtil.getCardType()) {
            BaseConstant.CARD_TEACHER_MANAGER -> {
                "gzaStudentOutList"
            }
            BaseConstant.CARD_PRESIDENT->{
                "headStudentOutList"
            }
            else -> {
                "studentOutList"
            }
        }
    }

    companion object {
        fun newInstance(state: String): MakeUpCourseFragment {
            val fragment = MakeUpCourseFragment()
            val bundle = Bundle().apply {
                putString(BaseConstant.KEY_ID, state)
            }
            fragment.arguments = bundle
            return fragment
        }
    }
}